home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
EAGUI
/
EAFrames.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
7KB
|
212 lines
(*************************************************************************
$RCSfile: EAFrames.mod $
Description: Bordered frame for EAGUI.
Created by: fjc (Frank Copeland)
$Revision: 1.2 $
$Author: fjc $
$Date: 1995/06/04 23:20:15 $
Copyright © 1995, Frank Copeland.
This file is part of the Oberon-A Library.
See Oberon-A.doc for conditions of use and distribution.
*************************************************************************)
<* STANDARD- *>
<*$ StackChk- *>
<*$ LongVars+ *>
MODULE EAFrames;
IMPORT
SYS := SYSTEM, Kernel, s := Sets, e := Exec, u := Utility,
gfx := Graphics, i := Intuition, gt := GadTools, ea := EAGUI;
CONST
(* Border rendering flags. *)
DoubleBorder* = 0; (* Render a double border like the string gadget
* border, otherwise use a BevelBox.
*)
Recessed* = 1; (* Draw a recessed border, otherwise draw a raised
* one.
*)
InnerBorder* = 2; (* Draw the border around the inner edge of the border
* zone, otherwise around the outer edge.
*)
TYPE
(* Information that is needed by this object, but that isn't maintained
* by EAGUI itself.
*)
FramePtr * = POINTER [2] TO Frame;
Frame * = RECORD [2]
flags * : s.SET32; (* different flags *)
shinePen *,
shadowPen * : e.UBYTE; (* pens to use *)
visInfo * : gt.VisualInfo; (* for drawing BevelBox *)
END;
VAR
RenderHook * : u.HookPtr;
rhook : u.Hook;
(*************************************************************************
* *
* Render Method *
* *
*************************************************************************)
PROCEDURE Render*
( hook : u.HookPtr;
obj : ea.OPTR;
rm : ea.RenderMessagePtr )
: e.ULONG;
VAR
frm : FramePtr;
width, height, left, top, bl, br, bt, bb, ignore : e.ULONG;
l, t, w, h : e.UWORD;
pen1, pen2 : e.UBYTE;
group : ea.OPTR;
tag : u.TagID; data : u.Tag;
BEGIN (* Render *)
(* get a pointer to our structure, and check if we actually got it *)
frm := SYS.VAL (FramePtr, ea.GetAttr (obj, ea.UserData));
IF frm # NIL THEN
(* get the container object *)
group := SYS.VAL (ea.OPTR, ea.GetAttr (obj, ea.Parent));
ASSERT (group # NIL, 96);
(* get sizes of the object *)
ignore := ea.GetAttrs ( group,
ea.Width, SYS.ADR (width),
ea.Height, SYS.ADR (height),
u.done );
(* get offsets of object relative to root (window) *)
left := ea.GetObjectLeft (rm.root_ptr, group);
top := ea.GetObjectTop (rm.root_ptr, group);
IF ~(InnerBorder IN frm.flags) THEN
ignore := ea.GetAttrs ( group,
ea.BorderLeft, SYS.ADR (bl),
ea.BorderRight, SYS.ADR (br),
ea.BorderTop, SYS.ADR (bt),
ea.BorderBottom, SYS.ADR (bb),
u.done );
DEC (left, bl); DEC (top, bt);
INC (width, bl + br); INC (height, bt + bb)
END;
IF DoubleBorder IN frm.flags THEN
IF Recessed IN frm.flags THEN
pen1 := frm.shadowPen; pen2 := frm.shinePen
ELSE
pen2 := frm.shadowPen; pen1 := frm.shinePen
END;
l := SHORT (left); t := SHORT (top);
w := SHORT (width); h := SHORT (height);
gfx.Move (rm.rastport_ptr, l, t);
gfx.SetAPen (rm.rastport_ptr, pen1);
gfx.Draw (rm.rastport_ptr, l + w - 1, t);
gfx.SetAPen (rm.rastport_ptr, pen2);
gfx.Draw (rm.rastport_ptr, l + w - 1, t + h - 1);
gfx.Draw (rm.rastport_ptr, l, t + h - 1);
gfx.SetAPen (rm.rastport_ptr, pen1);
gfx.Draw (rm.rastport_ptr, l, t);
gfx.Move (rm.rastport_ptr, l + 1, t + 1);
gfx.SetAPen (rm.rastport_ptr, pen2);
gfx.Draw (rm.rastport_ptr, l + w - 2, t + 1);
gfx.SetAPen (rm.rastport_ptr, pen1);
gfx.Draw (rm.rastport_ptr, l + w - 2, t + h - 2);
gfx.Draw (rm.rastport_ptr, l + 1, t + h - 2);
gfx.SetAPen (rm.rastport_ptr, pen2);
gfx.Draw (rm.rastport_ptr, l + 1, t + 1);
ELSE
IF Recessed IN frm.flags THEN tag := gt.bbRecessed; data := TRUE
ELSE tag := u.ignore
END;
gt.DrawBevelBox ( rm.rastport_ptr,
left, top, width, height,
gt.visualInfo, frm.visInfo,
tag, data,
u.done )
END
END;
(* return success *)
RETURN 0
END Render;
(*************************************************************************
* *
* Constructors *
* *
*************************************************************************)
PROCEDURE xNewFrame () : ea.OPTR;
<*$ ReturnChk- *>
BEGIN (* xNewFrame *)
SYS.SETREG (0,
ea.NewObject ( ea.TYPE_CUSTOMIMAGE,
ea.BorderLeft, 0,
ea.BorderRight, 0,
ea.BorderTop, 0,
ea.BorderBottom, 0,
ea.RenderMethod, RenderHook,
ea.UserData, SYS.REG (8), (* frm *)
u.more, SYS.REG (9), (* tags *)
u.done ))
END xNewFrame;
PROCEDURE [4] NewFrame* ["EAFrames_xNewFrame"]
( VAR frm [8] : Frame;
tags [9].. : u.Tag )
: ea.OPTR;
PROCEDURE [4] NewFrameA* ["EAFrames_xNewFrame"]
( VAR frm [8] : Frame;
tags [9] : u.TagListPtr )
: ea.OPTR;
PROCEDURE InitFrame*
( VAR frm : Frame;
flags : s.SET32;
visInfo : gt.VisualInfo;
drawInfo : i.DrawInfoPtr );
BEGIN (* InitFrame *)
frm.flags := flags;
IF drawInfo # NIL THEN
frm.shinePen := SHORT (drawInfo.pens [i.shinePen]);
frm.shadowPen := SHORT (drawInfo.pens [i.shadowPen]);
ELSE
frm.shinePen := 2; frm.shadowPen := 1
END;
frm.visInfo := visInfo
END InitFrame;
(************************************************************************)
<*$ LongVars- *>
PROCEDURE Init;
BEGIN (* Init *)
RenderHook := SYS.ADR (rhook);
u.InitHook (RenderHook, SYS.VAL (u.HookFunc, Render));
END Init;
BEGIN
Init
END EAFrames.